import java.util.Scanner;

abstract class Animal {
    public int age;
    public String name;
    public Animal(int age, String name) {
        this.age = age;
        this.name = name;
    }
   /* public void Eat(){};*/
    abstract void Eat();
    abstract void Break();
}
class Cat extends Animal{

    public Cat(int age, String name) {
        super(age, name);
    }
    public void Eat() {
        System.out.println(name+"在吃猫粮");
    }
    public void Break(){
        System.out.println(name+"在猫叫");
    }
}
class Duck extends Animal {
    public Duck(int age,String name){

        super(age,name);
    }
    public  void Eat() {

        System.out.println(name+"在吃鸭食");
    }
    public void Break(){

        System.out.println(name+"在鸭叫");
    }
}
public class Main{
    /*public static Animal func(){
        System.out.println("1>>Cat"+" "+"2>>Duck");
        Scanner scanner=new Scanner(System.in);
        int scan= scanner.nextInt();
        if(scan==1){
            return new Cat(12,"xx");
        }else {
            return new Dack(12,"xx");
        }
    }*/
    public static void main(String[] args) {
        /*while(true) {
            Animal animal = func();
            animal.Break();
            animal.Eat();
        }*/
        Cat cat=new Cat(12,"xx");//实例化子类对象
        Duck duck=new Duck(12,"xx");//实例化子类对象
        Animal animal=cat;//子类对象直接赋值
        Animal animal2=duck;//子类对象直接赋值
        animal.Break();//向上转型，
        animal2.Break();
    }
}
/*
abstract class A{
    abstract public void A();//抽象方法
}
class B extends A{
    @Override
    public void A() {//覆写抽象方法
        System.out.println("hallo world!");//有具体的实现
    }
}
public class Main{
    public static void main(String[] args) {
       B b=new B();
    }
}*/
